<div id="wechat_profile_container">


	<form id="profileForm" class="form-horizontal">

		<h4 class="header blue bolder smaller">微信公众号配置</h4>

		<input type="hidden" name="id" id="id" />
		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.appid"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="appId"
						required="required" name="appId" />
				</div>
			</div>
		</div>
		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.secret"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="secret"
						required="required" name="secret" />
				</div>
			</div>
		</div>
		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.token"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="token"
						required="required" name="token" />
				</div>
			</div>
		</div>
		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.aesKey"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="aesKey"
						required="required" name="aesKey" />
				</div>
			</div>
		</div>

		<h4 class="header blue bolder smaller">微信支付配置</h4>


		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.mchId"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="mchId"
						required="required" name="mchId" />
				</div>
			</div>
		</div>


		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.subAppId"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="subAppId" name="subAppId" />
				</div>
			</div>
		</div>


		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.subMchId"></label>
				<div class="col-xs-8">
					<input type="text" class="form-control" id="subMchId" name="subMchId" />
				</div>
			</div>
		</div>
		
		<div class="row" style="padding-bottom: 2px">
			<div class="form-group">
				<label class="col-xs-3 control-label" i18n="wechat.keyPath"></label> 
				<div class="col-xs-8">
					<input type="text" class="form-control" id="keyPath" name="keyPath" />
				</div>
			</div>
		</div>

		<div class="form-actions center">

			<button id="submitBtn" class="btn btn-success" type="button">
				<i class="ace-icon fa fa-check bigger-110"></i> <span i18n="submit"></span>
			</button>
			<button class="btn" type="reset">
				<i class="ace-icon fa fa-undo bigger-110"></i>重置
			</button>

		</div>

	</form>

</div>


<script>
    var scripts = [ null, null ]
    $('.page-content-area').ace_ajax('loadScripts', scripts, function() {

	var $container = $('#wechat_profile_container');
	var lang = $.homeGlobal.LANG.replace('_', "-");
	$.loy.i18n([ 'i18n/wechat/wechat' ], $.homeGlobal.LANG, $container, {
	    custCallback : function() {

	    }
	});

 

	$.loy.ajax({
	    url : 'wechat/config/get',
	    success : function(data) {
			var result = data.data;
			$('#id', $container).val(result.id);
			$('#appId', $container).val(result.appId ? result.appId : '');
			$('#aesKey', $container).val(result.aesKey ? result.aesKey :'');
			$('#token', $container).val(result.token ? result.token : '');
			$('#secret', $container).val(result.secret ? result.secret : '');
			$('#subAppId', $container).val(result.subAppId ? result.subAppId : '');
			$('#subMchId', $container).val(result.subMchId ? result.subMchId : ''); 
			$('#mchId', $container).val(result.mchId ? result.mchId : ''); 
			$('#mchKey', $container).val(result.mchKey ? result.mchKey : ''); 
			$('#keyPath', $container).val(result.keyPath ? result.keyPath : ''); 
	    }
	});

	$('#submitBtn', $container).click(function() {
 
		$.loy.ajax({
		    url : 'wechat/config/update',
		    showSuccess : true,
			    data : $("#profileForm", $container).serialize(),
		    success : function(data) {
				if (data.success) {
				}
		    }
		});
	     
	});

    });
</script>
